Skip to content

Notify viewers when documents update - #28

Merged
rgarcia merged 7 commits into
mainfrom
hypeship/doc-update-prompt
Aug 30, 2026
Merged

Notify viewers when documents update#28
rgarcia merged 7 commits into
mainfrom
hypeship/doc-update-prompt

Conversation

@ehfeng

@ehfeng ehfeng commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

summary

  • poll a lightweight, viewer-authorized version endpoint every 30 seconds while the document is visible
  • show an explicit updated · refresh control when newer content exists
  • reload normally when the viewer chooses to refresh

tests

  • npm test
  • npx tsc --noEmit
  • npm run build

Note

Medium Risk
Touches viewer auth/session behavior for a new hot path and changes how /d/* abuse is throttled (edge firewall vs in-app DB limits); cache invalidation must stay aligned with writes or viewers may see stale version numbers briefly.

Overview
Adds live “document updated” awareness in the viewer shell: while the tab is visible, the client polls a new lightweight GET /d/:slug/version endpoint every 30 seconds and shows an updated · refresh control when the server version is newer than what the page loaded with. A full reload is explicit (user click); inline-edit 409 conflicts also surface the same refresh affordance.

The version route returns plain text with private, no-store, reuses viewer auth (view token / public skip session; otherwise getSessionReadOnly so polling does not slide session expiry), and reads through a tagged unstable_cache (30s) invalidated on every document mutation path in store.

Viewer rate limiting moves from per-IP Postgres counters on /d/:slug/raw and preview to a Vercel firewall rule on /d/ (300 req / 60s / IP). Ops get npm run firewall:configure plus DEVELOPMENT.md notes; RL_VIEWER_PER_MIN and related app-side checks are removed.

Reviewed by Cursor Bugbot for commit a403259. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
justhtml Ready Ready Preview Aug 29, 2026 12:07am

@ehfeng
ehfeng marked this pull request as ready for review August 28, 2026 20:30
@ehfeng
ehfeng requested a review from rgarcia August 28, 2026 20:30

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 62676ddff7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/d/[slug]/CommentsShell.tsx

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 62676dd. Configure here.

Comment thread app/d/[slug]/version/route.ts

@rgarcia rgarcia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed incrementally — implementation, authorization boundaries, cache invalidation, polling behavior, and tests look good.

@rgarcia
rgarcia merged commit b027f7e into main Aug 30, 2026
5 checks passed
@rgarcia
rgarcia deleted the hypeship/doc-update-prompt branch August 30, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants